#  Copyright (C) 2010 Luca Piccinelli
# 
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.

'''
Created on Jul 2, 2011

@author: picci
'''

class GraphArc:
    #****** ComputationWidgetBuilder*************************************
    """ Models an arc of a graph """
    #********************************************************************
    def __init__(self, nodes = None):
        self.nodes = nodes
        self.observers = []
        
    def addObserver(self, observer):
        self.observers.append(observer)
        observer.addArc(self)
        
    def delete(self):
        for ob in self.observers:
            ob.removeArc(self)    
        
class GraphNode:
    #****** ComputationWidgetBuilder*************************************
    """ Models a node of a graph """
    #********************************************************************
    def __init__(self, arcs = None):
        if arcs: self.arcs = arcs
        else: self.arcs = []
        
    def addArc(self, arc):
        self.arcs.append(arc)   
            
        
class IOKeyGroupNode(GraphNode):
    #****** Computation Widget ******************************************
    """ A Node of a graph that contains information about an IOKeyGroup """             
    #********************************************************************
    def __init__(self, 
                 label_text, 
                 container_rect, 
                 container_position, 
                 evt_position, 
                 arcs = None):
        super().__init__(arcs)
        self.label_text = label_text
        self.container_rect = container_rect
        self.container_position = container_position
        self.evt_position = evt_position
        
    def moveNotified(self, move):
        self.container_position += move
        self.evt_position       += move         